package com.weixing.mall.provider.controller.admin;

import com.google.common.collect.Lists;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.model.dto.SealMatchRuleDto;
import com.weixing.mall.provider.service.ISealMatchRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Author wx
 * @Date 2019/10/8 9:27
 * @Version 1.0
 */
@RequestMapping("sealMatchRule")
@RestController
@Api(value = "封单匹配规则Api",tags = "封单匹配规则")
public class SealMatchRuleController extends BaseController {

    @Autowired
    private ISealMatchRuleService sealMatchRuleService;


    @ApiOperation(value = "查询")
    @GetMapping("")
    public Result selectOfPage(){
        return ResultUtil.success(sealMatchRuleService.selectOfPage(initMpPage()));
    }

    @ApiOperation(value = "新增")
    @PostMapping("save")
    public Result save(SealMatchRuleDto sealMatchRuleDto){
        sealMatchRuleService.save(sealMatchRuleDto);
        return ResultUtil.success();
    }

    @ApiOperation(value = "批量删除")
    @PostMapping("delAll/{ids}")
    public Result delAll(@PathVariable int[] ids){
        for (int id : ids) {
            sealMatchRuleService.removeById(id);
        }
//        sealMatchRuleService.removeByIds(Collections.singleton(ids));
        return ResultUtil.success();
    }

}
